﻿#!/bin/bash
. ${0%`basename ${0}`}edw_parm.sh
. ${0%`basename ${0}`}edw_func.sh

V_QUERY="update etl.EDW_LOAD_DATA_JOB set STATUS='' where STATUS <> 'DONE'"
${V_RUN_DB} -q "${V_QUERY}"
V_QUERY="select * from etl.EDW_LOAD_DATA_JOB where STATUS=''"
${V_RUN_DB} -q "${V_QUERY}"
data_date=$1
data_table=$2
index_table=$3

#建立hive-hbase映射表
hive -v -f ././../ddl/hive/ODS.DEPB_INFO_HBASE.DDL

#phoenix建数据表
psql.py ././../ddl/phoenix/DEPB_INFO.DDL

#给hive-hbase映射表同步数据
hive -hiveconf DATA_DATE=20180630 -v -f ././../proc/ODS/ODS.DEPB_INFO_HBASE.HQL

#给hbase数据表进行拆分
cd ${DWHDP_HOME}/tools/big_data_cluter_help
bash start_hbase_help.sh -Dhbase.region.merge.enable=false -Dhbase.region.split.enable=true \
    -Dhbase.region.balance.enable=false -Dhbase.table.majorCompact.enable=false -Dhbase.table.check=DEPB_INFO

#重建索引表
psql.py ././../ddl/phoenix/INDEX_DEPB_INFO.DDL
hbase org.apache.phoenix.mapreduce.index.IndexTool --data-table DEPB_INFO --index-table INDEX_DEPB_INFO --output-path ASYNC_IDX_HFILES --direct --run-foreground

#给hbase数据表、索引表进行拆分
cd ${DWHDP_HOME}/tools/big_data_cluter_help
bash start_hbase_help.sh -Dhbase.region.merge.enable=false -Dhbase.region.split.enable=true \
    -Dhbase.region.balance.enable=false -Dhbase.table.majorCompact.enable=false -Dhbase.table.check=DEPB_INFO,INDEX_DEPB_INFO
bash start_hbase_help.sh -Dhbase.region.merge.enable=false -Dhbase.region.split.enable=false \
    -Dhbase.region.balance.enable=true -Dhbase.table.majorCompact.enable=false -Dhbase.table.check=DEPB_INFO,INDEX_DEPB_INFO

#测试查询
sqlline.py hadoop01,hadoop02,hadoop03:2181 <<!EOF
explain select * FROM DEPB_INFO limit 10;
select * FROM DEPB_INFO limit 10;
explain select count(DATA_DATE) FROM DEPB_INFO;
select count(DATA_DATE) FROM DEPB_INFO;
!quit
!EOF
